import 'dviceInfo_BGFMBD.dart';

class DeviceInfoBGFMBD {
  final String deviceImage; // 图片
  final String deviceName; // App显示名字
  final String dName; // 设备真实名字
  final String deviceMac; // mac地址
  final DeviceType deviceType; // 类型
  final String txCharacteristicUUID; // 写的UUID
  final String rxCharacteristicUUID; // 读的UUID
  final int currentModel; // 当前模式 0 - 7
  final bool isCurrentSelected; // 是否是当前选中
  final int timing; // 胸贴定时时间 0 没有定时 1->5分钟 2->10分钟 3->15分钟

  DeviceInfoBGFMBD({
    required this.deviceImage,
    required this.deviceName,
    required this.dName,
    required this.deviceMac,
    required this.deviceType,
    required this.txCharacteristicUUID,
    required this.rxCharacteristicUUID,
    required this.currentModel,
    required this.isCurrentSelected,
    required this.timing,
  });

  // 可选：添加一个 fromJson 工厂方法，用于从 JSON 数据创建对象
  factory DeviceInfoBGFMBD.fromJson(Map<String, dynamic> json) {
    return DeviceInfoBGFMBD(
      deviceImage: json['device_image'],
      deviceName: json['device_name'],
      dName: json['d_name'],
      deviceMac: json['device_mac'],
      deviceType: DeviceType.values[json['device_type']],
      txCharacteristicUUID: json['txCharacteristicUUID'],
      rxCharacteristicUUID: json['rxCharacteristicUUID'],
      currentModel: json['current_model'],
      isCurrentSelected: json['is_current_selected'],
      timing: json['timing'],
    );
  }

  // 可选：添加一个 toJson 方法，用于将对象转换为 JSON
  Map<String, dynamic> toJson() {
    return {
      'device_image': deviceImage,
      'device_name': deviceName,
      'd_name': dName,
      'device_mac': deviceMac,
      'device_type': deviceType.index,
      'txCharacteristicUUID': txCharacteristicUUID,
      'rxCharacteristicUUID': rxCharacteristicUUID,
      'current_model': currentModel,
      'is_current_selected': isCurrentSelected,
      'timing': timing,
    };
  }
}
